<template>
    <div class="question_wrap">
        <p class="question_title">问卷调查：</p>
        <div v-for="(item, index) in answer_querstion" :key="index">
            <SingleProblem v-if="item.questionType == 1" :details="item" :index-id="index" />
            <ShortProblem v-if="item.questionType == 2" :details="item" :index-id="index" />
        </div>
    </div>
</template>
<script>
import { Button, Popup, Toast } from 'vant'
import SingleProblem from '@/components/question/SingleProblem.vue' 
import ShortProblem from '@/components/question/ShortProblem.vue' 
import jsons from '../../public/txt.json'
import { eventBus} from '@/components/eventBus'
export default {
    components: {
        SingleProblem,
        ShortProblem,
        Button,
        Popup,
        Toast
    },
    data() {
        return {
            answer_querstion: []
        }
    },
    created() {
        console.log('源数据',jsons)
        this.answer_querstion = jsons.data
        
    },
    mounted() {
        eventBus.$on('addQuestion', msg => {
            console.log('--------------', msg)
            msg.data.forEach(item => {
                this.answer_querstion.splice(msg.indexId, 0, item)
                // this.answer_querstion.push(item)
            })
            console.log(this.answer_querstion)
        })
    }
}

</script>

<style scoped>
.question_wrap {
    padding: 15px;
    box-sizing: border-box;
    
}
.question_title {
        font-size: 14px;
        color: #172b4d;
        font-weight: 600;
        margin: 20px 0 10px 0;
    }
.questionbtn {
    width: 100%;
    text-align: center;
    
}
.btn {
        width: 50%;
        margin: 20px;
    }
</style>
